package com.xckj.service.impl;
import org.springframework.stereotype.Service;

import com.xckj.dao.JacgAllowedClassPrefixMapper;
import com.xckj.entity.JacgAllowedClassPrefix;
import com.xckj.service.JacgAllowedClassPrefixService;
import com.xckj.utils.ReturnT;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @description 允许处理的类名或包名前缀
 * @author yanchf
 * @date 2023-11-26
 */
@Service
public class JacgAllowedClassPrefixServiceImpl implements JacgAllowedClassPrefixService {

	@Resource
	private JacgAllowedClassPrefixMapper jacgAllowedClassPrefixMapper;


	@Override
	public Object insert(JacgAllowedClassPrefix jacgAllowedClassPrefix) {

		// valid
		if (jacgAllowedClassPrefix == null) {
			return ReturnT.error("必要参数缺失");
        }

		jacgAllowedClassPrefixMapper.insert(jacgAllowedClassPrefix);
        return ReturnT.success();
	}


	@Override
	public Object delete(int id) {
		int ret = jacgAllowedClassPrefixMapper.delete(id);
		return ret>0?ReturnT.success():ReturnT.error();
	}


	@Override
	public Object update(JacgAllowedClassPrefix jacgAllowedClassPrefix) {
		int ret = jacgAllowedClassPrefixMapper.update(jacgAllowedClassPrefix);
		return ret>0?ReturnT.success():ReturnT.error();
	}


	@Override
	public JacgAllowedClassPrefix load(int id) {
		return jacgAllowedClassPrefixMapper.load(id);
	}


	@Override
	public Map<String,Object> pageList(int offset, int pagesize) {

		List<JacgAllowedClassPrefix> pageList = jacgAllowedClassPrefixMapper.pageList(offset, pagesize);
		int totalCount = jacgAllowedClassPrefixMapper.pageListCount(offset, pagesize);

		// result
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("pageList", pageList);
		result.put("totalCount", totalCount);

		return result;
	}

}